//index.js
//获取应用实例
const app = getApp()

Page({

  data: {
   type:'',
   score:'',
   is_pass:1,
   subject:''
  },
  
  onLoad: function () {
    var test_result = wx.getStorageSync('test_result');
    wx.removeStorageSync('test_result');
    var is_pass     = test_result.score < 90 ? 0:1;
    this.setData({
      type:test_result.type,
      score:test_result.score,
      is_pass:is_pass,
      subject:test_result.subject
    })
  },
 
  onShareAppMessage: function (res) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
    }
    var title = this.data.type + '科目' + this.data.subject+'模拟考试结果';
    return {
      title: title,
      path: '/pages/index/index'
    }
  },
  backIndex:function(){
    if(this.data.subject == '一'){
      var subject = 1;
    }
    if (this.data.subject == '四') {
      var subject = 4;
    }
    wx.removeStorageSync(this.data.type + '_number_test_' + subject);
    wx.removeStorageSync(this.data.type + '_test_' + subject);
    wx.reLaunch({
      url: '/pages/index/index',
    })
  }
})
